//
//  SEGMenuListManager.h
//  FrameworkTest
//
//  Created by 刘山 on 2018/4/8.
//  Copyright © 2018年 刘山. All rights reserved.
//

#import <Foundation/Foundation.h>
#import "CommomHeader.h"
#import "SEGMenuListModel.h"
#import "SEGPgcManager.h"
#import "SEGMenuQuizTypeList.h"
#import "SEGPictorialListModel.h"

#import "GDTNativeExpressAdView.h"

#import "SEGOldPGCListViewLayout.h"

typedef void (^testBlock)(BOOL hasTopLine, BOOL hasAd, BOOL hasCommonMenu, NSArray<SEGNeighborRollViewModel *> *neighborTopLineData);
typedef void (^hotnewsBlock)(BOOL hasHotNews);


@interface SEGMenuListManager : NSObject

/// 将 一个 menuModel.childList 拆分成多个 menuModel.childList
/// @param menuModel 原数据
/// @param tempSectionData 临时数组, 存放menuModel
/// @param row  每个menuModel包含几个元素
+ (void)menuList_packagingRowToSEGMenuListModel:(SEGMenuListModel *)menuModel
                                     sectionArr:(NSMutableArray *)tempSectionData
                                            row:(NSUInteger)row;

/**
 查询菜单数据中是否存在导航栏，存在返回数据模型，不存在返回nil

 @param data 原菜单导航栏数据源
 @return 导航栏数据模型
 */
+(SEGMenuListModel*) segGetNavigationBarData:(NSArray<NSArray<SEGMenuListModel *> *> *)data;
#pragma mark - ==============v4.8.0优化版本==============
/**
 实时侧滑推荐位数据
 
 @author Sam
 @version 4.8.0
 */
-(void)segRefreshHotNewsWithParams:(NSDictionary*)params Finished:(hotnewsBlock)finished;
#pragma mark - ==============v4.7.0优化版本==============
/**
 实时请求邻里头条数据
 
 @author Sam
 @version 4.7.0
 */
-(void)segNeighborToplineFinished:(testBlock)finished;

#pragma mark - ==============v4.6.0优化版本==============
/*本地菜单数据-邻里头条-测滑推荐位-PGC---> 主线程刷新*/
-(void)segAsyncGetLocalDataWithAction:(NSString*)action PositionType:(SEGAdvlistType)type settingsId:(NSString*)settingsId finished:(testBlock)finished;

/**
 * 请求网络数据
 * 菜单数据->通过菜单数据中控件类型去请求相应的网络数据
 * @author Sam
 * @version 4.6.0
 */
-(void)segReqqustMenuDataAndBusinessDataWithMenuSid:(NSString*)menuSid
                                             action:(NSString*)action
                                       PositionType:(SEGAdvlistType)type
                                         settingsId:(NSString*)settingsId
                                      hotNewsParams:(NSDictionary*)hotNewsParams
                                           targetVC:(UIViewController*)targetVC
                                           Finished:(testBlock)finished;

/**
 * 获取服务器底部Tab菜单数据
 * @author Sam
 * @version 4.6.0
 */

-(void)segRequestMenuListForTabBarV2Finished:(SEGNetworkReponse)finished;

/**
 * 手动刷新PGC数据
 * @author Sam
 * @version 4.6.0
 */
-(void)segManualRequstPGCFinished:(void(^)(BOOL isSuccessed, NSInteger index))finished;

/// 根据PGC id请求对应实体
/// @param idArray idArray
/// @param finished finished
-(void)segManualRequstPGCWithIDArray:(NSArray *)idArray finished:(void(^)(BOOL isSuccessed, NSInteger index))finished;

#pragma mark - ==============v4.6.0优化版本==============

@property (nonatomic, strong)SEGPgcManager *pgcManager;
/** 菜单数据源 */
@property (nonatomic, strong)NSArray<NSArray<SEGMenuListModel *> *> *menuListDataArr;
@property (nonatomic, strong)NSArray<SEGMenuListModel*>* dataSourceTabBar;
/**
 老PGC数据源
 */
@property (nonatomic, strong) NSArray<SEGOldPGCListViewLayout*>* oldPGCDataSource;
/**
 老PGC列表刷新条数
 */
@property (nonatomic, assign) NSInteger oldPGCFreshCount;

/**
 * 获取本地的业务数据进行展示
 * @author Sam
 */
-(void)segShowLocalDataWithAction:(NSString*)action settingsId:(NSString*)settingsId PositionType:(SEGAdvlistType)type finished:(SEGNetworkReponse)finished;

-(void)segRequestMenuListWithMenuSid:(NSString*)menuSid
                              action:(NSString*)action
                          settingsId:(NSString*)settingsId
                        PositionType:(SEGAdvlistType)type
                         tencentSource:(NSArray<GDTNativeExpressAdView*> *)code
                       hotNewsParams:(NSDictionary*)hotNewsParams
                            finished:(SEGNetworkReponse)finished;

/**
 请求PGC列表数据
 @author Sam
 @version 4.6.0
 @param pageNo 页数
 @param pageSize 每页总数
 @param quizTypeId PGC类型
 @param isRecommend 是否是推荐位
 */
-(void)requestOldPGCListPageNo:(NSInteger)pageNo PageSize:(NSInteger)pageSize quizTypeId:(NSString*)quizTypeId isRecommend:(NSString*)isRecommend finished:(SEGNetworkReponse)finished;

/**
 * 刷新PGC数据，并且进行和主数据源进行绑定
 * @author Sam
 */
-(void)segFreshPgcDataWithTencentSource:(NSArray<GDTNativeExpressAdView*> *) source finished:(SEGNetworkReponse)finished;

// 请求邻里头条
-(void)requestTopLineFinished:(SEGNetworkReponse)finished;

/**
 * 保存菜单数据
 * @author Sam
 */
-(void)segSaveMenuListData:(NSArray<SEGMenuListModel*>*)data localPath:(NSString*)action;

/**
 * 获取菜单数据
 * @author Sam
 */
-(NSArray<SEGMenuListModel*>*)segGetMenuListDataWithLocalPath:(NSString*)action;

/*
 * 将一维数组转换为二维数组
 1. 通过 disGroup 字段去重, 分组,
 2. 组内通过rn排序,
 3. 通过 widgetType 控件类型进行展示
 */
+ (NSArray<NSArray<SEGMenuListModel *> * >*)seg_menuListCategory:(NSArray<SEGMenuListModel *> *)data;

/**
 * 保存邻里头条到本地路径
 * @author Sam
 */
+(BOOL)segSaveNeighborTopLineWithData:(NSArray<SEGNeighborRollViewModel*>*)data;

/**
 * 获取邻里头条
 * @author Sam
 */
+(NSArray<SEGNeighborRollViewModel*>*)segGetNeighborTopLine;

#pragma mark - 侧滑位缓存操作
/**
 * 保存邻里头条到本地路径
 * @author Sam
 */
+(BOOL)segSaveHotNewsWithData:(NSArray<SEGSquareViewModel*>*)data;

/**
 * 获取邻里头条
 * @author Sam
 */
+(NSArray<SEGSquareViewModel*>*)segGetHotNews;

@end
